
CFLAGS := -std=gnu99 -g
# CFLAGS += -I$(PWD)/binutils/include 
# LDFLAGS := -L$(PWD)/binutils/lib64 -L/home/long/Downloads/tmp/binutils-2.30/libiberty -L/home/long/Downloads/tmp/binutils-2.30/zlib
# LDFLAGS += -Wl,-Bstatic -lopcodes  -lbfd -liberty -lz -Wl,-Bdynamic -ldl -lc

LDFLAGS += -lopcodes  -lbfd -liberty -lz -ldl -lc

AARCH_CC := aarch64-linux-gnu-gcc
AARCH_OBJDUMP := aarch64-linux-gnu-objdump

# all: test test-x86 a64.ao
all: elf-dis
	$(AARCH_OBJDUMP) -d a64.ao > a64.asm

elf-dis: elf-dis.o
	gcc $^ $(LDFLAGS) -o $@
	# ./elf-dis

test-x86: test-x86.o
	gcc $^ $(LDFLAGS) -o $@
	./test-x86

test: test.o
	gcc $^ $(LDFLAGS) -o $@

%.o: %.c
	gcc $(CFLAGS) -c -g -o $@ $^ 

%.ao: %.S
	$(AARCH_CC) -c $^ -o $@

clean:
	rm *.o *.ao *.asm